package com.wlz.utils;

/**
 * 常用的工具类
 */
public class CommonUtils {

    /**
     * 验证手机号码
     *
     * @param phone 手机号码
     * @return 是否符合要求
     */
    public static Boolean verityPhone(String phone) {
        boolean flag = false;
        String regex = "^1(3|4|5|7|8|9)\\d{9}$";
        if (phone.matches(regex)) {
            flag = true;
        }
        return flag;
    }

    /**
     * 生成规则设备编号:五位编号（从1开始，不够前补0）
     *
     * @param equipmentNo
     *              最新编号
     * @return
     */
    public static String getNewEquipmentNo(String equipmentNo){
        String newEquipmentNo = "00001";

        if(equipmentNo != null && !equipmentNo.isEmpty()){
            int newEquipment = Integer.parseInt(equipmentNo) + 1;
            newEquipmentNo = String.format("%05d", newEquipment);
        }

        return newEquipmentNo;
    }

    public static void main(String[] args) {
        String equipmentNo = getNewEquipmentNo( "00032");
        System.out.println("生成设备编号：" + equipmentNo);
    }

}
